package config

import "gitee.com/imshann/um-common/utils"

type Config struct {
	filepath string
	config   map[string]interface{}
}

func OpenFile(filepath string) *Config {
	if filepath == "" {
		panic("filepath is empty")
	}
	var config = utils.JsonDecode(utils.ReadFile(filepath))
	return &Config{filepath, config.(map[string]interface{})}
}

func (c *Config) Get(key string) (value any) {
	if _, ok := c.config[key]; ok {
		return c.config[key]
	}
	return nil
}
